package com.ymatou.iapi.exp.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonObject;
import com.ymatou.iapi.exp.parameter.GetUserCoinTradingStatusBean;
import com.ymatou.iapi.exp.service.GetUserCoinTradingStatusCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.ExpCallService;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;
/**
*获取金币交易状态
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetUserCoinTradingStatus{
	private static GetUserCoinTradingStatusBean getusercointradingstatusBean;
	private static GetUserCoinTradingStatusCall getusercointradingstatusCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取金币交易状态");
	}

	@Before
	public void caseUp() {
		getusercointradingstatusBean=new GetUserCoinTradingStatusBean();
		getusercointradingstatusCall=new GetUserCoinTradingStatusCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getusercointradingstatusCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetUserCoinTradingStatus_001() {
		Logger.start(true,"获取金币交易状态成功");
		try {
			int uid = TestDataManager.getRandomIntNum(2)+1;
			String bizcode="200101";
			String bizno= YMTDateUtil.getSysTime("yyyyMMddHHmmssSSS");
			ExpCallService.ChangeUserCoin(uid, bizcode,bizno, 100);
			getusercointradingstatusBean.setUserId(uid);
			getusercointradingstatusBean.setBizCode(bizcode);
			getusercointradingstatusBean.setBizNo(bizno);
			getusercointradingstatusCall.setData(getusercointradingstatusBean);
			getusercointradingstatusCall.callService();			
			JsonObject result = getusercointradingstatusCall.getJsonObject().get("Data").getAsJsonObject();
			Logger.verifyEquals("true", result.get("success").toString(), "验证success");
			Logger.verifyEquals("0", getusercointradingstatusCall.getString("BCode"), "验证BCode");
			Logger.verifyEquals("true", result.get("tradingSuccess").toString(), "验证tradingSuccess");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_GetUserCoinTradingStatus_002() {
		Logger.start(true,"不输入userid查询结果false");
		try {
			int uid = TestDataManager.getRandomIntNum(2)+1;
			String bizcode="200101";
			String bizno= YMTDateUtil.getSysTime("yyyyMMddHHmmssSSS");
			ExpCallService.ChangeUserCoin(uid, bizcode,bizno, 100);
//			getusercointradingstatusBean.setUserId(uid);
			getusercointradingstatusBean.setBizCode(bizcode);
			getusercointradingstatusBean.setBizNo(bizno);
			getusercointradingstatusCall.setData(getusercointradingstatusBean);
			getusercointradingstatusCall.callService();			
			JsonObject result = getusercointradingstatusCall.getJsonObject().get("Data").getAsJsonObject();
			Logger.verifyEquals("true", result.get("success").toString(), "验证success");
			Logger.verifyEquals("0", getusercointradingstatusCall.getString("BCode"), "验证BCode");
			Logger.verifyEquals("false", result.get("tradingSuccess").toString(), "验证tradingSuccess");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_GetUserCoinTradingStatus_003() {
		Logger.start(true,"不输入bizcode查询结果false");
		try {
			int uid = TestDataManager.getRandomIntNum(2)+1;
			String bizcode="200101";
			String bizno= YMTDateUtil.getSysTime("yyyyMMddHHmmssSSS");
			ExpCallService.ChangeUserCoin(uid, bizcode,bizno, 100);
			getusercointradingstatusBean.setUserId(uid);
//			getusercointradingstatusBean.setBizCode(bizcode);
			getusercointradingstatusBean.setBizNo(bizno);
			getusercointradingstatusCall.setData(getusercointradingstatusBean);
			getusercointradingstatusCall.callService();			
			JsonObject result = getusercointradingstatusCall.getJsonObject().get("Data").getAsJsonObject();
			Logger.verifyEquals("true", result.get("success").toString(), "验证success");
			Logger.verifyEquals("0", getusercointradingstatusCall.getString("BCode"), "验证BCode");
			Logger.verifyEquals("false", result.get("tradingSuccess").toString(), "验证tradingSuccess");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_GetUserCoinTradingStatus_004() {
		Logger.start(true,"不输入bizno,失败");
		try {
			int uid = TestDataManager.getRandomIntNum(2)+1;
			String bizcode="200101";
			String bizno= YMTDateUtil.getSysTime("yyyyMMddHHmmssSSS");
			ExpCallService.ChangeUserCoin(uid, bizcode,bizno, 100);
			getusercointradingstatusBean.setUserId(uid);
			getusercointradingstatusBean.setBizCode(bizcode);
//			getusercointradingstatusBean.setBizNo(bizno);
			getusercointradingstatusCall.setData(getusercointradingstatusBean);
			getusercointradingstatusCall.callService();			
			JsonObject result = getusercointradingstatusCall.getJsonObject().get("Data").getAsJsonObject();
			Logger.verifyEquals("false", result.get("success").toString(), "验证success");
			Logger.verifyEquals("1", getusercointradingstatusCall.getString("Code"), "验证Code");
			Logger.verifyEquals("false", result.get("tradingSuccess").toString(), "验证tradingSuccess");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_GetUserCoinTradingStatus_005() {
		Logger.start(true,"输入不存在数据,失败");
		try {
			int uid = TestDataManager.getRandomIntNum(2)+1;
			String bizcode="200101";
			String bizno= YMTDateUtil.getSysTime("yyyyMMddHHmmssSSS");
//			ExpCallService.ChangeUserCoin(uid, bizcode,bizno, 100);
			getusercointradingstatusBean.setUserId(uid);
			getusercointradingstatusBean.setBizCode(bizcode);
			getusercointradingstatusBean.setBizNo(bizno);
			getusercointradingstatusCall.setData(getusercointradingstatusBean);
			getusercointradingstatusCall.callService();			
			JsonObject result = getusercointradingstatusCall.getJsonObject().get("Data").getAsJsonObject();
			Logger.verifyEquals("true", result.get("success").toString(), "验证success");
			Logger.verifyEquals("0", getusercointradingstatusCall.getString("BCode"), "验证BCode");
			Logger.verifyEquals("false", result.get("tradingSuccess").toString(), "验证tradingSuccess");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}